import 'package:elephant_fish/model/user_info_entity.dart';

class VoiceRoomEntity {
  int roomId;
  int person;
  String title;
  int joinLevel;
  Owner owner;
  List<UserInfoEntity> users;

  VoiceRoomEntity(
      {this.roomId,
        this.person,
        this.title,
        this.joinLevel,
        this.owner,
        this.users});

  VoiceRoomEntity.fromJson(Map<String, dynamic> json) {
    roomId = json['room_id'];
    person = json['person'];
    title = json['title'];
    joinLevel = json['join_level'];
    owner = json['owner'] != null ? new Owner.fromJson(json['owner']) : null;
    if (json['users'] != null) {
      users = new List<UserInfoEntity>();
      json['users'].forEach((v) {
        users.add(new UserInfoEntity.fromJson(v));
      });
    }
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['room_id'] = this.roomId;
    data['person'] = this.person;
    data['title'] = this.title;
    data['join_level'] = this.joinLevel;
    if (this.owner != null) {
      data['owner'] = this.owner.toJson();
    }
    if (this.users != null) {
      data['users'] = this.users.map((v) => v.toJson()).toList();
    }
    return data;
  }
}

class Owner {
  int id;
  int userId1;
  int roomId;
  String secondPassword;
  String avatar;
  String signature;
  int sex;
  int age;
  String interest;
  String city;
  String nickname;
  String wechat;
  int experience;
  int level;
  int rechargeAmount;
  int sendAmount;
  String birthday;
  int privacy;
  String userId;

  Owner(
      {this.id,
        this.userId1,
        this.roomId,
        this.secondPassword,
        this.avatar,
        this.signature,
        this.sex,
        this.age,
        this.interest,
        this.city,
        this.nickname,
        this.wechat,
        this.experience,
        this.level,
        this.rechargeAmount,
        this.sendAmount,
        this.birthday,
        this.privacy,
        this.userId});

  Owner.fromJson(Map<String, dynamic> json) {
    id = json['id'];
    userId1 = json['user_id'];
    roomId = json['room_id'];
    secondPassword = json['second_password'];
    avatar = json['avatar'];
    signature = json['signature'];
    sex = json['sex'];
    age = json['age'];
    interest = json['interest'];
    city = json['city'];
    nickname = json['nickname'];
    wechat = json['wechat'];
    experience = json['experience'];
    level = json['level'];
    rechargeAmount = json['recharge_amount'];
    sendAmount = json['send_amount'];
    birthday = json['birthday'];
    privacy = json['privacy'];
    userId = json['userId'];
  }

  Map<String, dynamic> toJson() {
    final Map<String, dynamic> data = new Map<String, dynamic>();
    data['id'] = this.id;
    data['user_id'] = this.userId1;
    data['room_id'] = this.roomId;
    data['second_password'] = this.secondPassword;
    data['avatar'] = this.avatar;
    data['signature'] = this.signature;
    data['sex'] = this.sex;
    data['age'] = this.age;
    data['interest'] = this.interest;
    data['city'] = this.city;
    data['nickname'] = this.nickname;
    data['wechat'] = this.wechat;
    data['experience'] = this.experience;
    data['level'] = this.level;
    data['recharge_amount'] = this.rechargeAmount;
    data['send_amount'] = this.sendAmount;
    data['birthday'] = this.birthday;
    data['privacy'] = this.privacy;
    data['userId'] = this.userId;
    return data;
  }
}